﻿<!DOCTYPE html>

<html lang="zh-cn">

<head>
    <meta charset="utf-8">
    <title>Shadow Editor</title>
    <link rel="shortcut icon" href="favicon.ico">
    <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
    <!-- iconfont -->
    <link href="assets/css/icon/iconfont.css" rel="stylesheet" />
    <!-- Shadow Editor -->
    <link href="assets/css/main.css" rel="stylesheet" />
    <link id="theme" href="assets/css/light.css" rel="stylesheet" />
</head>

<body>
    <div id="container" tabindex="10"></div>

    <!-- three.js -->
    <script src="assets/js/three.js"></script>

    <!-- libs -->
    <script src="assets/js/libs/stats.min.js"></script>
    <script src="assets/js/libs/jszip.min.js"></script>
    <script src="assets/js/libs/inflate.min.js"></script>
    <script src="assets/js/libs/gunzip.min.js"></script>
    <script src="assets/js/d3/d3.js"></script>
    <script src="assets/js/libs/rbush.js"></script>

    <script src="assets/js/SimplexNoise.js"></script>
    <script src="assets/js/ImprovedNoise.js"></script>
    <script src="assets/js/GPUComputationRenderer.js"></script>
    <script src="assets/js/ShaderTerrain.js"></script>

    <script src="assets/js/SPE.js"></script>
    <script src="assets/js/VolumetricFire.js"></script>
    <script src="assets/js/utils/BufferGeometryUtils.js"></script>

    <!-- controls -->
    <script src="assets/js/controls/EditorControls.js"></script>
    <script src="assets/js/controls/TransformControls.js"></script>

    <!-- geometries -->
    <script src="assets/js/geometries/DecalGeometry.js"></script>
    <script src="assets/js/geometries/TeapotBufferGeometry.js"></script>

    <!-- loaders -->
    <script src="assets/js/loaders/TGALoader.js"></script>

    <!-- shaders -->
    <script src="assets/js/shaders/FXAAShader.js"></script>

    <!-- objects -->
    <script src="assets/js/objects/Sky.js"></script>
    <script src="assets/js/objects/Reflector.js"></script>
    <script src="assets/js/objects/Lensflare.js"></script>

    <!-- Shadow Editor -->
    <script src="build/ShadowEditor.js"></script>
    <script>
        var container = null;
        var app = null;

        var lang = window.localStorage.getItem('lang') || 'zh-CN';

        var loadJs = url => {
            var script = document.createElement('script');
            script.type = 'text/javascript';
            script.src = url;

            document.body.appendChild(script);

            return new Promise(resolve => {
                script.onload = () => {
                    resolve();
                }
            });
        };

        var start = () => {
            container = document.getElementById('container');
            app = new Shadow.Application(container, {
                server: location.origin,
                enableTileCache: false,
            });
            app.start();
        };

        window.onload = () => {
            if (lang === 'zh-CN') {
                loadJs('lang/zh-CN.js').then(() => {
                    start();
                });
            } else {
                start();
            }
        };
    </script>
</body>

</html>